import request from '@/utils/request'


export function getDocumentList(pageNum,pageSize,DocumentVo) {
  console.log(DocumentVo)
  return request({
    url: `/document/documentGetAll/${pageNum}/${pageSize}`,
    method: 'post',
    data:DocumentVo
  })
}

export function documentGetId(id) {
  return request({
    url: `/document/documentGetId/${id}`,
    method: 'get',
  })
}

export function getUserAll() {
  return request({
    url: `/announcement/getUserAll`,
    method: 'get',
  })
}

export function handleDelete(recycleID,userID) {
  return request({
    url: `/document/documentDelete/${recycleID}/${userID}`,
    method: 'delete',
  })
}

export function submitForm(addDocumentsList) {
  console.log(addDocumentsList)
  return request({
    url: `/document/documentAdd`,
    method: 'post',
    data:addDocumentsList
  })
}

export function updateForm(updateDocumentsList) {
  console.log(updateDocumentsList)
  return request({
    url: `/document/documentUpdate`,
    method: 'put',
    data:updateDocumentsList
  })
}



// 解决ERROR ResizeObserver loop completed with undelivered notifications.
// 重写ResizeObserver的构造函数，并在其中定义并调用防抖函数
window.ResizeObserver = class ResizeObserver extends window.ResizeObserver {
  constructor(callback) {
    let timer = null;
    const debouncedCallback = function () {
      let context = this;
      let args = arguments;
      clearTimeout(timer);
      timer = setTimeout(function () {
        callback.apply(context, args);
      }, 16);
    };
    super(debouncedCallback);
  }
};
